//
//  SettingViewController.m
//  ENTBoostChat
//
//  Created by zhong zf on 14-10-15.
//  Copyright (c) 2014年 EB. All rights reserved.
//

#import "OtherViewController.h"
#import "AppDelegate.h"
#import "LogonViewController.h"
#import "ENTBoost.h"
#import "ENTBoostChat.h"

@interface OtherViewController ()

@end

@implementation OtherViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    //设置标题
    //self.navigationItem.title = @"设置";
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0 || section == 1)
        return 1;
    
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"OtherCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    
    switch (indexPath.section) {
        case 0:
        {
            cell.textLabel.textAlignment = NSTextAlignmentLeft;
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.imageView.image = [UIImage imageNamed:@"head"];
            cell.backgroundColor = [UIColor whiteColor];
            cell.textLabel.text = @"设置头像[建设中]";
            
        }
            break;
        case 1:
        {
            cell.textLabel.textAlignment = NSTextAlignmentCenter;
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.backgroundColor = [UIColor grayColor];
            cell.textLabel.text = @"退出登录";
        }
            break;
        default:
            break;
    }
    
    return cell;
}

#pragma - mark UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO]; //取消选中
    
    NSLog(@"indexPath section = %i, row = %i", indexPath.section, indexPath.row);
    
    switch (indexPath.section) {
        case 0:
        {
            
            
        }
            break;
        case 1:
        {
            if (indexPath.row == 0) { //退出登录
                UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"退出登录" message:@"真得要退出吗？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"注销", nil];
                [alertView show];
            }
        }
            break;
        default:
            break;
    }
}

//退出登录提示处理
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1) {
        [[NSNotificationCenter defaultCenter] postNotificationName:EBCHAT_NOTIFICATION_MANUAL_LOGOFF object:self userInfo:nil];
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
